﻿using System;


using System.Text;
using IAM.Interface.Model.Interface;
using System.Xml;
using IAM.Interface.Model.ENUM;

namespace IAM.Interface.Model
{
    /// <summary>
    /// 所有日志记录列表
    /// </summary>
    public class Logs : AbstractConvertObject, IConvertXml
    {
        #region 构造函数
        public Logs()
        {
            _logs = new System.Collections.ArrayList();
        }
        #endregion
        #region 属性
        private System.Collections.ArrayList _logs;
        /// <summary>
        /// 日志记录集合【log集合】
        /// </summary>
        public System.Collections.ArrayList Items
        {
            get
            {
                return _logs;
            }
            set
            {
                _logs = value;
            }
        }
        /// <summary>
        /// 日志记录的数量
        /// </summary>
        public int Count
        {
            get
            {
                return this.Items.Count;
            }
        }
        #endregion
        #region IConvertXml

        public string XMLBoday
        {
            get
            {
                StringBuilder _xml = new StringBuilder();
                _xml.Append("<Logs");
                _xml.Append(" Count=\"" + this.Count + "\"");
                _xml.Append(" >");
                foreach (object item in Items)
                {
                    _xml.Append(((Log)item).XML);
                }
                return _xml.ToString();
            }


        }

        public string XMLFinis
        {
            get
            {
                return "</Logs>";
            }
        }
        public string XML
        {
            get
            {
                return XMLBoday + XMLFinis;
            }
        }
        #endregion
        #region AbstractConvertObject
        public override object ConvertToObject()
        {
            foreach (XmlNode xn in this.CurrentXmlNode.ChildNodes)
            {
                Log log = new Log();
                log.CurrentXmlNode = xn;
                log = (Log)log.ConvertToObject();
                this.Items.Add(log);
            }
            return this;
        }
        #endregion
    }
}
